package Threads.JMM;

public class Visual_volatile {
    static volatile boolean run=true;
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            while (run){
                //System.out.println("I am running");
                //代码
            }
        },"t1");

        t.start();
        Thread.sleep(2000);
        //System.out.println("run to false");
        run=false;
    }
}
